updating tests
authorØyvind Kolås <ok@src.gnome.org>
Fri, 9 Sep 2005 11:10:30 +0000 (11:10 +0000)
committerØyvind Kolås <ok@src.gnome.org>
Fri, 9 Sep 2005 11:10:30 +0000 (11:10 +0000)
ChangeLog
tests/conversions.c
tests/srgb_to_lab_u8.c
tests/types.c

index d6aa9ae90c09f9cd7e67508b944329694c9005a9..0c8cb01e91431a0951aac7f7662aabeb8a29785f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2005-09-09  Øyvind Kolås  <pippin@gimp.org>
+
+       * tests/conversions.c: (validate_conversion): do relative average
+       error calculations.
+       * tests/srgb_to_lab_u8.c: update values.
+       * tests/types.c: set a very low tolerance.
+
 2005-09-09  Øyvind Kolås  <pippin@gimp.org>
 
        * babl/babl-format.c: (create_name): Create shorter names when
index f8703bd9e2104f5bbd1781fe924e5ecee579910c..6c1ba8dba97cfb4c75324a52ea74dd276535da9c 100644 (file)
@@ -7,9 +7,11 @@
 
 int OK=1;
 
-#define pixels    102400
+#define pixels    512
 #define TOLERANCE 0.001
 
+#define ERROR_TOLERANCE 0.5
+
 double test[pixels * 4];
 
 double r_interval (double min, double max)
@@ -70,6 +72,8 @@ validate_conversion (BablConversion *conversion)
   Babl *fmt_source      = BABL(conversion->source);
   Babl *fmt_destination = BABL(conversion->destination);
 
+  double error=0.0;
+  
   void    *source;
   void    *destination;
   double  *destination_rgba_double;
@@ -97,38 +101,53 @@ validate_conversion (BablConversion *conversion)
 
   {
     int i;
-    int log=0;
+    int cnt=0;
 
     for (i=0;i<pixels;i++)
       {
         int j;
+        int log=0;
         for (j=0;j<4;j++)
+          {
+            error += fabs (destination_rgba_double[i*4+j] - 
+                            ref_destination_rgba_double[i*4+j]);
+
            if (fabs (destination_rgba_double[i*4+j] - 
                      ref_destination_rgba_double[i*4+j])>TOLERANCE)
-             {
-                if (!log)
-                  log=1;
-                OK=0;
-             }
-        if (log && log < 5)
+                log=1;
+          }
+        if (0 && log && cnt < 5)
           {
+            /* enabling this code prints out the RGBA double values at various stages,
+             * which are used for the average relative error
+             */
+          
             babl_log ("%s", conversion->instance.name);
-            babl_log ("\ttest:           %2.3f %2.3f %2.3f %2.3f", test [i*4+0],
+            babl_log ("\ttest:           %2.5f %2.5f %2.5f %2.5f", test [i*4+0],
                                                                    test [i*4+1],
                                                                    test [i*4+2],
                                                                    test [i*4+3]);
-            babl_log ("\tconversion:     %2.3f %2.3f %2.3f %2.3f", destination_rgba_double [i*4+0],
+            babl_log ("\tconversion:     %2.5f %2.5f %2.5f %2.5f", destination_rgba_double [i*4+0],
                                                                    destination_rgba_double [i*4+1],
                                                                    destination_rgba_double [i*4+2],
                                                                    destination_rgba_double [i*4+3]);
-            babl_log ("\tref_conversion: %2.3f %2.3f %2.3f %2.3f", ref_destination_rgba_double [i*4+0],
+            babl_log ("\tref_conversion: %2.5f %2.5f %2.5f %2.5f", ref_destination_rgba_double [i*4+0],
                                                                    ref_destination_rgba_double [i*4+1],
                                                                    ref_destination_rgba_double [i*4+2],
                                                                    ref_destination_rgba_double [i*4+3]);
-            log++;
+            cnt++;
             OK=0;
           }
       }
+     error /= pixels;
+     error *= 100;
+
+     conversion->error = error;
+     if (error >= ERROR_TOLERANCE)
+       {
+          babl_log ("%s\terror:%f", conversion->instance.name, error);
+          OK = 0;
+       }
   }
 
   
index 19b5c25c9351e25f8a85791d2349f3b5f6a8d2f6..f973101ea7934859c801a512e3e813f49183615b 100644 (file)
@@ -33,11 +33,11 @@ unsigned char source_buf [PIXELS*3]=
 
 unsigned char reference_buf [PIXELS*3]=
   {  0, 128, 128,
-   135, 128, 127,
-   254, 127, 128,
-   135, 207, 195,
-   222,  42, 210,
-    81, 206,  20};
+   136, 128, 128,
+   255, 128, 128,
+   136, 208, 195,
+   224,  42, 211,
+    82, 207,  20};
 
 unsigned char destination_buf [PIXELS*3];
 
index 8e7616413fe11f73770996ca62e3bd469219e7b7..5c71ad02e096c45d70ca2714bccf5bd8aec375f0 100644 (file)
@@ -3,7 +3,7 @@
 
 int OK=1;
 
-#define TOLERANCE 0.0046
+#define TOLERANCE 0.000000001
 #define samples   2048
 double test[samples];